<script type="text/javascript">
    (function ($) {
        function tdI(b,c) {
            var temp1 = '', temp2 = '', temp3 = '';
            for (var i = 0; i < 3; i++) {
                temp1 += `<td height="40"></td>`;
            }
            for (var i = 0; i < 4; i++) {
                temp2 += `<td height="15"></td>`;
                temp3 += `<td height="10"></td>`;
            }
            return `<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" ${b}>
                        <tbody>
                            <tr>
                                ${temp1}
                            </tr>
                            <tr>
                                <td width="60"></td>
                                <td style="background:#${c};">
                                    <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" style="border:1px solid #ff0313;">
                                        <tbody>
                                            <tr>
                                                ${temp2}
                                            </tr>
                                            <tr>
                                                <td width="30"></td>
                                                <td width="390" style='font-family: 'microsoft yahei',Arial, Helvetica,Arial,sans-serif;'>
                                                    <a href="#" style="display: block;text-decoration: none;font-size:16px;">
                                                        <span style="font-size: 16px;line-height: 20px;display: block;color:#000;margin:0px 0px 20px 0px;">
                                                            <span style="font-size:24px;">Xiaomi
                                                                <span style="color:#ff0313;">Mi Max</span>
                                                            </span>
                                                            <br>3GB 32GB 6.44'' 4850mAh Dorado
                                                        </span>
                                                        <span style="font-size:14px;color: #000;text-decoration: line-through;display: block;line-height: 18px;">299.99€</span>
                                                        <span style="font-size: 20px;color:#ff0313;line-height: 30px;display: block;margin: 0px 0px 10px 0px;">
                                                            <span style="font-size:30px;font-weight:bold;">239</span>.99€</span>
                                                        </span>
                                                        <span style="display: block;width:130px;height: 35px;line-height: 35px;background:#e53935;color:#fff;font-size:16px;text-align: center;">Comprar &gt;&gt;</span>
                                                    </a>
                                                </td>
                                                ${tdH()}
                                                <td width="20"></td>
                                            </tr>
                                            <tr>
                                                ${temp3}
                                            </tr>
                                        </tbody>
                                    </table>
                                </td>
                                <td width="60"></td>
                            </tr>
                        </tbody>
                    </table>`
        }
        function tdH() {
            var temp1 = '';
            for(var i = 0; i < 2; i++){
                temp1 += `<img src="./images/201608293-${i + 1}.png" alt="" style="width:100%;margin:0px;border:0px;padding:0px;display: block;">`
            }
            return ` <td>
                        <a href="#" style="display: block;">
                            ${temp1}
                        </a>
                    </td>`
        }
        function tdT(item) {
            return `<td width="210">
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" style="border:1px solid #ff0313;">
                            <tbody>
                                <tr>
                                    <td style="padding:3px;font-family: 'microsoft yahei',Arial, Helvetica,Arial,sans-serif;">
                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" style="border:1px solid #ff0313;">
                                            <tbody>
                                                <tr>
                                                    <td ${item=='2'?'style="background: #ff0313;"':''}>
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                                                            <tbody>
                                                                <tr>
                                                                    <td height="10"></td>
                                                                </tr>
                                                                <tr>
                                                                    ${tdH()}
                                                                </tr>
                                                                <tr>
                                                                    <td height="5"></td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td ${item=='1'?'style="background: #ff0313;"':''}>
                                                        <a href="#l" style="display: block;text-decoration: none;text-align:center;padding:0px;">
                                                            <span style="font-size: 16px;line-height: 20px;display: block;color:#${item=='1'?'fff':'333'};margin:5px 0px;">
                                                                Xiaomi
                                                                <span style="color:#${item=='1'?'fff100':'ff0313'};">Redmi Pro</span>
                                                                <br>3GB 64GB Dorado
                                                            </span>
                                                            <span style="font-size: 20px;color:#${item=='1'?'fff100':'ff0313'};line-height: 25px;display: block;margin: 0px">
                                                                <span style="font-size:14px;color: #${item=='1'?'fff':'333'};text-decoration: line-through;line-height: 18px;">259.99€</span>
                                                                <span style="font-size:30px;font-weight:bold;">239</span>
                                                                <span>.99€</span>
                                                            </span>
                                                            <span style="background:#${item=='1'?'fff100':'ff0313'};color:#${item=='1'?'ff0313':'fff'};font-size:16px;text-align: center;display: block;margin:5px auto;width:70%;height:30px;line-height: 30px;">Comprar &gt;&gt;</span>
                                                        </a>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>`
        }
        function t1(item){
            return `<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                        <tbody>
                            <tr>
                                <td height="${item}"></td>
                            </tr>
                        </tbody>
                    </table>`
        }
        var str1 = `<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                        <tbody>
                            <tr>
                                <td width="25"></td>
                                ${tdT('1')}
                                <td width="10"></td>
                                ${tdT('1')}
                                <td width="10"></td>
                                ${tdT('1')}
                                <td width="25"></td>
                            </tr>
                        </tbody>
                    </table>`;
        var str10 = `<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                                <tbody>
                                    <tr>
                                        <td>
                                            <a href="#">
                                                <img src="./images/201701191.jpg" style="width:700px;height:350px;margin:0px;border:0px;padding:0px;display: block;" alt="liquidacion total 2017">
                                            </a>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="background:url(./images/201701199.jpg) repeat-y center top;">
                                            ${tdI('style="background: url(./images/201701198.jpg) no-repeat center top;"','fff') + t1('15') + str1}
                                            ${t1('10') + str1}
                                            ${t1('25') + tdI('','D4C4B5') +　t1('15')}
                                            <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                                                <tbody>
                                                    <tr>
                                                        <td width="25"></td>
                                                        ${tdT('2')}
                                                        <td width="10"></td>
                                                        ${tdT('2')}
                                                        <td width="10"></td>
                                                        ${tdT('2')}
                                                        <td width="25"></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                            ${t1('10')}
                                            <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                                                <tbody>
                                                    <tr>
                                                        <td width="135"></td>
                                                        ${tdT('2')}
                                                        <td width="10"></td>
                                                        ${tdT('2')}
                                                        <td width="135"></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                            <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                                                <tbody>
                                                    <tr>
                                                        <td>
                                                            <img src="./images/2017011910.jpg" style="width:100%;margin:0px;border:0px;padding:0px;display: block;" alt="">
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="background:#D8101D">
                                            <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                                                <tbody>
                                                    <tr>
                                                        <td height="15"></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="font-family: 'microsoft yahei',Arial, Helvetica,Arial,sans-serif;">
                                                            <a href="#" style="display: block;text-decoration: none;text-align: center;height:30px;line-height:30px;">
                                                                <span style="padding: 5px 10px;background:#e53935;color:#fff;font-size:16px;text-align: center;border: 1px solid #fff;">Ver más &gt;&gt;</span>
                                                            </a>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td height="15"></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>`;
        $("#main").prepend(str10);
    })(jQuery);
</script>